package Thread;
//单例模式(饿汉模式）
class Singleton{
    private static Singleton instance = new Singleton();
    public static Singleton getInstance(){
        return instance;
    }
    private Singleton(){}
}
public class Demo15 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
//        Singleton s3 = new Singleton();//此时就会报错，因为不能够对Singleton这个类进行实例化新的对象
        System.out.println(s1 == s2);
    }
}
